--GO

--
-- Definition of table `form_controls`
--

CREATE TABLE `form_controls` (
  `FormControlID` VARCHAR(64) NOT NULL DEFAULT newid(),
  `ControlType` INT(10) NOT NULL,
  `Control` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ControlName` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `RequiresRows` TINYINT NOT NULL,
  `RequiresColumns` TINYINT NOT NULL,
  PRIMARY KEY (`FormControlID`)
)
ENGINE = INNODB;

--GO

--
-- Definition of table `form_answerrowcolumn`
--

CREATE TABLE `form_answerrowcolumn` (
  `FormResponseID` VARCHAR(64) NOT NULL,
  `FormQuestionID` VARCHAR(64) NOT NULL,
  `FormAnswerID` VARCHAR(64) NOT NULL,
  `FormRowID` VARCHAR(64) NOT NULL,
  `FormColumnID` VARCHAR(64) NULL,
  `IsSelected` TINYINT NOT NULL, 
  PRIMARY KEY (`FormAnswerID`)
)
ENGINE = INNODB;

--GO

--
-- Definition of table `form_answer`
--

CREATE TABLE `form_answer` (
  `FormResponseID` VARCHAR(64) NOT NULL,
  `FormQuestionID` VARCHAR(64) NOT NULL,
  `FormAnswerID` VARCHAR(64) NOT NULL,
  `Answer` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  PRIMARY KEY (`FormAnswerID`)
)
ENGINE = INNODB;

--GO

--
-- Definition of table `form_response`
--

CREATE TABLE `form_response` (
  `FormID` VARCHAR(64) NOT NULL,
  `FormResponseID` VARCHAR(64) NOT NULL,
  `TakenBy` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `TakenDate` DATETIME NOT NULL,
  `Reviewed` TINYINT NULL,
  `ReviewedBy` VARCHAR(64) NULL,
  `ReviewerComments` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `ReviewedDate` DATETIME NULL,
  PRIMARY KEY (`FormResponseID`)
)
ENGINE = INNODB;

--GO

--
-- Definition of table `form_question`
--

CREATE TABLE `form_question` (
  `FormID` VARCHAR(64) NOT NULL,
  `FormQuestionID` VARCHAR(64) NOT NULL,
  `Question` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `FormControlID` VARCHAR(64) NOT NULL,
  `FormControlWidth` INT(10) NULL,
  `FormControlHeight` INT(10) NULL,
  `FormControlRows` INT(10) NULL,
  `FormControlCols` INT(10) NULL,
  `FormControlLayout` INT(10) NULL,
  `FormPage` INT(10) NOT NULL,
  `IsRequired` TINYINT NULL,
  `RequiredText` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `IsRegularExpressionValidatorRequired` TINYINT NULL,
  `RegularExpression` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `RegularExpressionValidatorText` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `IsCompareValidatorRequired` TINYINT NULL,
  `CompareValidatorType` INT(10) NULL,
  `CompareValidatorText` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `IsRangeValidatorRequired` TINYINT NULL,
  `RangeValidatorText` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `RangeStart` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `RangeEnd` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `CreateDate` DATETIME NOT NULL,	
  `SortOrder` INT(10) NOT NULL,	
  `IsOtherOption` TINYINT NULL,
  `OtherOptionText` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,  
  PRIMARY KEY (`FormQuestionID`)
)
ENGINE = INNODB;

--GO

--
-- Definition of table `form`
--

CREATE TABLE `form` (
  `FormID` VARCHAR(64) NOT NULL,
  `FormName` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `AllowMultipleResponses` TINYINT NOT NULL,
  `CurrentUserID` VARCHAR(64) NULL,
  `IV_FormType` INT(10) NOT NULL,
  `ExpireDate` DATETIME NULL,
  `UserID` VARCHAR(64) NOT NULL,
  `FormCompleteMessage` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `CreateDate` DATETIME NOT NULL,
  `ModifiedUserID` VARCHAR(64) NULL,
  `ModifiedDate` DATETIME NULL,
  `RegisteredUserOnly` TINYINT NULL,    
  PRIMARY KEY (`FormID`)
)
ENGINE = INNODB;

--GO

--
-- Definition of table `form_questionrows`
--

CREATE TABLE `form_questionrows` (
  `FormQuestionID` VARCHAR(64) NOT NULL,
  `FormRowID` VARCHAR(64) NOT NULL,
  `RowChoice` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `CreateDate` DATETIME NOT NULL,	
  `IsOtherOption` TINYINT NOT NULL,    
  `SortOrder` INT(10) NOT NULL,	  
  PRIMARY KEY (`FormRowID`)
)
ENGINE = INNODB;

--GO

--
-- Definition of table `form_questioncolumns`
--

CREATE TABLE `form_questioncolumns` (
  `FormQuestionID` VARCHAR(64) NOT NULL,
  `FormColumnID` VARCHAR(64) NOT NULL,
  `ColumnChoice` VARCHAR(-1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `CreateDate` DATETIME NOT NULL,	
  `SortOrder` INT(10) NOT NULL,	  
  PRIMARY KEY (`FormColumnID`)
)
ENGINE = INNODB;